package com.zhangy.controller;
import com.zhangy.model.Zhuzhai;
import com.zhangy.service.ZhuzhaiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@CrossOrigin
@Transactional
@Controller
@ResponseBody
public class ZhuzhaiController {
    @Autowired
    private ZhuzhaiService zhuzhaiService ;

    @RequestMapping("addZhuzhai")
    public void addZhuzhai(Zhuzhai zhuzhai){
        zhuzhaiService.addZhuzhai(zhuzhai);
    }
    @RequestMapping("delZhuzhai")
    public void delZhuzhai(String ids){
        String[] split = ids.split(",");
        List<Integer> arrList=new ArrayList<Integer>();
        for (String idd: split) {
            arrList.add(Integer.parseInt(idd));
        }
        zhuzhaiService.delZhuzhai(arrList);
    }
    @RequestMapping("updateZhuzhai")
    public void updateZhuzhai(Zhuzhai zhuzhai){
        zhuzhaiService.updateZhuzhai(zhuzhai);
    }
    @RequestMapping("selZhuzhaiById")
    public Zhuzhai selZhuzhaiById(int zzid){
        return zhuzhaiService.selZhuzhaiById(zzid);
    }
    @RequestMapping("selectZhuzhaiList")
    public List<Zhuzhai> selectZhuzhaiList(){
        return zhuzhaiService.selectZhuzhaiList();
    }
}
